﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Complaint.aspx.cs" Inherits="WISD.CarFriend.Web.Admin.OA.ComplaintManage.Complaint" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>会员投诉管理</title>
    <link href="../../Content/CSS/ClientCSS/qlsale.css" rel="stylesheet" type="text/css" />
    <link href="../../Content/CSS/ClientCSS/Table.css" rel="stylesheet" type="text/css" />
    <link href="../../Content/CSS/ClientCSS/blue.css" rel="stylesheet" type="text/css" />
    <script src="/Admin/Scripts/ClientScripts/Page.js" type="text/javascript"></script>
    <script src="/Admin/Scripts/ClientScripts/CodyyForm.js" type="text/javascript"></script>
    <script src="/Admin/Scripts/ClientScripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="/Admin/Scripts/DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script src="/Admin/Scripts/ClientScripts/SplitPage.js" type="text/javascript"></script>
    <script src="/Admin/Scripts/ClientScripts/jquery.artDialog.min.js" type="text/javascript"></script>
    <script src="../../Scripts/WisdScript/Common.js" type="text/javascript"></script>
</head>
<body>
    <div style="height: auto;">
        <table class="adduser" align="center" border="0" cellpadding="0" cellspacing="0"
            width="100%" bgcolor="#F2F7F5">
            <tbody>
                <tr>
                    <td colspan="5" class="bigTitle" height="40">
                        <strong>会员投诉管理</strong>
                    </td>
                </tr>
                <tr>
                    <td class="sctitle_four">
                        会员满意度：
                    </td>
                    <td>
                        <select id="Sel_Satisfaction">
                            <option value="-1">--请选择会员满意度--</option>
                            <option value="0">满意</option>
                            <option value="1">不满意</option>
                        </select>
                    </td>
                    <td class="sctitle" style="width: 50px;">
                    </td>
                    <td class="sctitle" style="width: 81px;">
                        状态：
                    </td>
                    <td>
                        <select id="Sel_State">
                            <option value="0">--请选择状态--</option>
                            <option value="1">登记状态</option>
                            <option value="2">执行状态</option>
                            <option value="3">完成状态</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td colspan="5" class="fenline">
                        &nbsp;
                        <input value="搜索" class="twobtn" type="button" id="btnSearch" />&nbsp;&nbsp;
                    </td>
                </tr>
                <tr>
                    <td colspan="5">
                        <table rules="all" class="tableStyle">
                            <thead>
                                <tr>
                                    <th scope="col" style="display: none;">
                                        序号
                                    </th>
                                    <th scope="col">
                                        会员卡号
                                    </th>
                                    <th scope="col">
                                        会员姓名
                                    </th>
                                    <th scope="col">
                                        消费项目
                                    </th>
                                    <th scope="col">
                                        投诉方式
                                    </th>
                                    <th scope="col">
                                        开始时间
                                    </th>
                                    <th scope="col">
                                        结束时间
                                    </th>
                                    <th id="State" scope="col">
                                        会员满意度
                                    </th>
                                    <th scope="col">
                                        状态
                                    </th>
                                    <th scope="col">
                                        操作
                                    </th>
                                </tr>
                            </thead>
                            <tbody id="databody">
                            </tbody>
                            <tfoot id="footer" class="div_footer">
                            </tfoot>
                        </table>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
    <div id="registerdiv" class="registerdiv" style="width: 660px;">
        <table class="addTable" align="center" border="0" cellpadding="0" cellspacing="0"
            width="100%" style="margin-right: 20px;">
            <tbody>
                <tr class="topTitle">
                    <td colspan="4" style="margin-top: -3px;">
                        <ul>
                            <li class="leftli">会员投诉管理</li>
                            <li class="rightli" onclick="$('#registerdiv').hide();">
                                <img alt="关闭" title="关闭" id="close" src="/Admin/Content/Images/tdClose_Hover.png" /></li>
                        </ul>
                    </td>
                </tr>
                <tr>
                    <td class="sctitle_four">
                        会员编号：
                    </td>
                    <td>
                        <input id="txtMemberID" name="MemberID" class="stxt txtgray" type="text" readonly="readonly" />
                    </td>
                    <td class="sctitle_four">
                        会员姓名：
                    </td>
                    <td>
                        <input id="txtMemberName" name="MemberName" class="stxt txtgray" type="text" readonly="readonly" />
                    </td>
                </tr>
                <tr>
                    <td class="sctitle_four">
                        消费时间：
                    </td>
                    <td>
                        <input id="txtConsumeDate" name="ConsumeDate" class="stxt txtgray" type="text" readonly="readonly" />
                    </td>
                    <td>
                        特约商户负责人：
                    </td>
                    <td>
                        <input id="txtShopLeader" name="ShopLeader" class="stxt txtgray" type="text" readonly="readonly" />
                    </td>
                </tr>
                <tr>
                    <td class="sctitle_four">
                        车号：
                    </td>
                    <td>
                        <input id="txtVehicleNo" name="VehicleNo" class="stxt txtgray" type="text" readonly="readonly" />
                    </td>
                    <td class="sctitle_four">
                        消费项目：
                    </td>
                    <td>
                        <input id="ConsumeItem" name="ConsumeItem" class="stxt txtgray" type="text" readonly="readonly" />
                    </td>
                </tr>
                <tr>
                    <td class="sctitle_four">
                        投诉方式：
                    </td>
                    <td>
                        <select id="SelReturnVisitType" style="width: 120px;">
                            <option value="1">电话</option>
                        </select>
                    </td>
                    <td class="sctitle_four">
                        状态：
                    </td>
                    <td>
                        <select id="SelState" style="width: 120px;">
                            <option value="1">登记状态</option>
                            <option value="2">执行状态</option>
                            <option value="3">完成状态</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td class="sctitle_four">
                        开始时间：
                    </td>
                    <td>
                        <input id="txtStartTime" name="StartTime" class="stxt txtgray" type="text" readonly="readonly" />
                    </td>
                    <td class="sctitle_four">
                        结束时间：
                    </td>
                    <td>
                        <input id="txtEndTime" name="EndTime" class="stxt txtgray" type="text" readonly="readonly" />
                    </td>
                </tr>
                <tr>
                    <td class="sctitle_four">
                        受派员工:
                    </td>
                    <td>
                        <select id="SelBeSend" style="width: 120px;">
                        </select>
                    </td>
                    <td class="sctitle_four">
                        会员满意度：
                    </td>
                    <td>
                        <select id="Satisfaction" style="width: 120px;">
                            <option value="0">满意</option>
                            <option value="1">不满意</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td class="sctitle_four">
                        会员投诉：
                    </td>
                    <td>
                        <textarea id="Complaint" cols="30" rows="5" style="overflow: hidden; display: block;
                            resize: none;"></textarea>
                    </td>
                    <td class="sctitle_four">
                        处理结果：
                    </td>
                    <td>
                        <textarea id="Result" cols="30" rows="5" style="overflow: hidden; display: block;
                            resize: none;"></textarea>
                    </td>
                </tr>
                <tr>
                    <td class="sctitle_four">
                        备注：
                    </td>
                    <td>
                        <textarea id="Memo" cols="30" rows="5" style="overflow: hidden; display: block; resize: none;"></textarea>
                    </td>
                    <td class="sctitle_four">
                        修改记录：
                    </td>
                    <td>
                        <textarea id="updatelog" cols="27" rows="5" readonly="readonly" style="overflow: hidden;
                            display: block; resize: none; overflow: auto;" clear='yes'></textarea>
                    </td>
                </tr>
                <tr>
                    <td colspan="4" style="height: 15px;">
                    </td>
                </tr>
                <tr>
                    <td id="btnGroup" colspan="4" align="center" style="text-align: center;">
                        <input value="修改" id="btnEdit" class="twobtn" type="button" />&nbsp;&nbsp;
                    </td>
                </tr>
                <tr>
                    <td colspan="4" style="height: 15px;">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</body>
</html>
<script type="text/javascript">
    //获取员工表信息
    var LoadExmployee = function () {
        $.post("/Admin/Control/Complaint.ashx", { "Action": "GetEp" }, function (data) {
            if (!data) {
                $("#AssignEmployee").html("<option value=''>无</option>");
                return;
            }
            var jsonArr = eval("(" + data + ")");
            var citystr = "";
            for (var i = 0; i < jsonArr.length; i++) {
                citystr += "<option value=" + jsonArr[i]["EmployeeID"] + ">" + jsonArr[i]["Name"] + "</option>";
            }
            $("#AssignEmployee,#SelBeSend").html(citystr).change();
        });
    };

    //历史修改记录
    var LoadUpdateLog = function (ReturnVisitID) {
        $.post("/Admin/Control/Complaint.ashx", { "Action": "GetUpdateLog", "ReturnVisitID": ReturnVisitID }, function (data) {
            if (data) {
                var jsonArr = eval("(" + data + ")");
                var citystr = "";
                for (var i = 0; i < jsonArr.length; i++) {
                    citystr += jsonArr[i]["Reviser"] + "(" + jsonArr[i]["ReviseDate"] + ")\r\n";
                }
                $("#updatelog").val(citystr);
            }
        });
    };


    //赋值操作
    function EditEntity() {
        var rs = Page.Static.Rs[0];
        $("#txtMemberID").val(rs["MemberID"]);
        $("#txtMemberName").val(rs["Name"]);
        $("#txtConsumeDate").val(rs["ConsumeTime"].split(" ")[0]);
        $("#txtShopLeader").val(rs["ShopLeader"]);
        $("#txtVehicleNo").val(rs["VehicleNo"]);
        $("#ConsumeItem").val(rs["ConsumeItem"]);
        $("#SelReturnVisitType").val(rs["ReturnVisitType"]);
        $("#SelState").val(rs["StateID"]);
        $("#txtStartTime").val(rs["StartTime"].split(" ")[0]);
        $("#txtEndTime").val(rs["EndTime"].split(" ")[0].replace("1900/1/1", ""));
        $("#SelBeSend").val(rs["SendEmployee"]);
        $("#Satisfaction").val(rs["SatisfactionID"]);
        $("#Complaint").val(rs["Complaint"]);
        $("#Result").val(rs["Result"]);
        $("#Memo").val(rs["Memo"]);
    };

    //专门用来保存某个记录的详细消息
    var rs = {};

    $(function () {
        var MainPK = "";
        var Condition = "";
        var CurrentPage = 1;

        //失去焦点验证
        Form.Blur({ id: "registerdiv" });

        //添加修改记录
        var setEntity = function (obj) {
            var Result = Form.Validator({ id: "registerdiv" });
            if (Result) {
                var _$ = function (id) { return document.getElementById(id); };
                var data = {
                    Action: obj.Action
                     , ReturnVisitType: $.trim($("#SelReturnVisitType").val())
                     , State: $.trim($("#SelState").val())
                     , EndTime: $.trim($("#txtEndTime").val())
                     , SendEmployee: $.trim($("#SelBeSend").val())
                     , Satisfaction: $.trim($("#Satisfaction").val())
                     , Complaint: $.trim($("#Complaint").val())
                     , Result: $.trim($("#Result").val())
                     , Memo: $.trim($("#Memo").val())
                     , Reviser: ""
                     , ReviseDate: ""
                };
                if (obj.Action == "EditEntity") { data["Main"] = obj.Main; }
                $.post("/Admin/Control/Complaint.ashx", data, function (data) {
                    if (data.split(",")[0] === "Success") {
                        alert("修改成功!");
                        Condition = GetCondition();
                        CurrentPage = Page.Static.CurrentPage;
                        InitPage();
                        $("#registerdiv").hide();
                    }
                    else {
                        alert("修改失败!");
                    }
                });
            }
        }

        //获取查询条件
        var GetCondition = function () {
            var Sel_Satisfaction = $("#Sel_Satisfaction").val() || "0";  //会员满意度            
            var Sel_State = $("#Sel_State").val() || "0";  //状态
            return Sel_Satisfaction + "@" + Sel_State + "@1";
        };

        //加载数据
        var InitPage = function () {
            Page.GetData({ "Control": "/Admin/Control/Complaint.ashx", "Action": "Init", "first": true, "colspan": 10,
                "Condition": Condition, "databody": "databody", "footer": "footer", "ActionBtn": "<a href='javascript:;' action='edit'>[修改]</a>"
            });
        };

        //第一次加载数据
        Condition = GetCondition();
        InitPage();

        //重置表单
        var ResetForm = function () {
            $(".addTable").find("input[type='text'][clear='yes'],textarea[clear='yes']").val("");
            $(".addTable").find("input,textarea,select").attr("disabled", false);
        };

        //点击搜索按钮
        $("#btnSearch").click(function () {
            Condition = GetCondition();
            CurrentPage = 1;
            InitPage();
        });

        //点击修改按钮
        $("#btnEdit").click(function () {
            setEntity({ "Action": "EditEntity", "Main": MainPK });
        });

        //在Table中点击修改、删除 
        $("#databody").click(function (e) {
            var that = this;
            var e = e || window.event;
            var target = e.srcElement || e.target;
            if ($(target).is("a")) {
                var action = $(target).attr("action");
                var main = $(target).parent().parent().attr("main");
                MainPK = main;
                if (!action.localeCompare("edit")) {    //编辑
                    var state = $(target).parent().parent().children('[id=State]')[0].innerText;
                    if (state == "完成状态") {
                        alert("此记录已完成，无法再修改！");
                        return;
                    }

                    ResetForm();
                    LoadUpdateLog(main);
                    $("#btnEdit").show();
                    $(".leftli").html("修改会员投诉信息");
                    var divobj = $("#registerdiv");
                    LoadExmployee();
                    Page.divCenter(divobj[0]).GetOne({ "Main": main });
                }
                (! -[1, ]) ? e.cancelBubble = true : e.stopPropagation();
            }
        }).dblclick(function (e) {    //双击查看详细信息
            var that = this;
            var e = e || window.event;
            var target = e.srcElement || e.target;
            if ($(target.parentNode).is("tr")) {
                var main = $(target.parentNode).attr("main");
                ResetForm();
                LoadUpdateLog(main);
                $("#btnEdit").hide();
                $(".addTable").find("input,textarea,select").attr("disabled", true);
                $("#updatelog").attr("disabled", false);
                $(".leftli").html("会员投诉信息详细");
                var divobj = $("#registerdiv");
                Page.divCenter(divobj[0]).GetOne({ "Main": main });
                (! -[1, ]) ? e.cancelBubble = true : e.stopPropagation();
            }
        });
    });

    $("#SelState").change(function () {
        var SelectID = $("#SelState  option:selected'").val();
        if (SelectID == "3") {   //完成状态
            $("#txtEndTime").val(getNowFormatDate());
        }
        else {
            $("#txtEndTime").val("");
        }
    });

</script>
